package cn.lg.soar.cms.biz.modules.video.entity;

import cn.lg.soar.cms.api.enums.CommentControlEnum;
import cn.lg.soar.cms.api.enums.VideoStatusEnum;
import cn.lg.soar.core.annotations.constraints.group.Create;
import cn.lg.soar.core.annotations.constraints.group.Update;
import cn.lg.soar.database.base.entity.BaseEntity;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 视频
 * @author luguoxiang
 * @since 2025-02-23
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@Data
@Schema(description = "视频")
@TableName("lg_cms_video")
public class Video extends BaseEntity {

    /** 点击数 */
    @NotNull(message = "点击数不能为空", groups = { Create.class, Update.class })
    @ExcelProperty(value = "点击数")
    @Schema(description = "点击数")
    private Integer clinks;

    /** 收藏数 */
    @NotNull(message = "收藏数不能为空", groups = { Create.class, Update.class })
    @ExcelProperty(value = "收藏数")
    @Schema(description = "收藏数")
    private Integer collect;

    /** 评论数 */
    @NotNull(message = "评论数不能为空", groups = { Create.class, Update.class })
    @ExcelProperty(value = "评论数")
    @Schema(description = "评论数")
    private Integer comments;

    /** 封面 */
    @NotBlank(message = "封面不能为空", groups = { Create.class, Update.class })
    @ExcelProperty(value = "封面")
    @Schema(description = "封面")
    private String cover;

    /** 时长（秒） */
    @NotNull(message = "时长（秒）不能为空", groups = { Create.class, Update.class })
    @ExcelProperty(value = "时长（秒）")
    @Schema(description = "时长（秒）")
    private Integer duration;

    /** 分组id(0：默认分组) */
    @NotNull(message = "分组id(0：默认分组)不能为空", groups = { Create.class, Update.class })
    @ExcelProperty(value = "分组id(0：默认分组)")
    @Schema(description = "分组id(0：默认分组)")
    private Long groupId;

    /**  */
    @NotNull(message = "主键不能为空", groups = { Update.class })
    @ExcelIgnore
    @Schema(description = "主键")
    @TableId
    private Long id;

    /** 介绍 */
    @ExcelProperty(value = "介绍")
    @Schema(description = "介绍")
    private String introduce;

    /** 点赞数 */
    @NotNull(message = "点赞数不能为空", groups = { Create.class, Update.class })
    @ExcelProperty(value = "点赞数")
    @Schema(description = "点赞数")
    private Integer likes;

    /** 顺序 */
    @NotNull(message = "顺序不能为空", groups = { Create.class, Update.class })
    @ExcelProperty(value = "顺序")
    @Schema(description = "顺序")
    private Integer sort;

    /** 状态(0待发布，1已发布，2已下架) */
    @NotNull(message = "状态(0待发布，1已发布，2已下架)不能为空", groups = { Create.class, Update.class })
    @ExcelProperty(value = "状态(0待发布，1已发布，2已下架)")
    @Schema(description = "状态(0待发布，1已发布，2已下架)")
    private VideoStatusEnum status;

    @ExcelProperty(value = "评论控制(0关闭评论，1自动精选、2手动精选)")
    @Schema(description = "评论控制(0关闭评论，1自动精选、2手动精选)")
    private CommentControlEnum commentControl;

    @ExcelProperty(value = "发布时间（未发布是创建时间，发布时更新为发布时间）")
    @Schema(description = "发布时间（未发布是创建时间，发布时更新为发布时间）")
    private LocalDateTime publishTime;

    /** 标题 */
    @NotBlank(message = "标题不能为空", groups = { Create.class, Update.class })
    @ExcelProperty(value = "标题")
    @Schema(description = "标题")
    private String title;

    /** 文件地址 */
    @NotBlank(message = "文件地址不能为空", groups = { Create.class, Update.class })
    @ExcelProperty(value = "文件地址")
    @Schema(description = "文件地址")
    private String url;

    /** 乐观锁 */
    @NotNull(message = "乐观锁不能为空", groups = { Create.class, Update.class })
    @ExcelProperty(value = "乐观锁")
    @Schema(description = "乐观锁")
    private Integer version;

    @JsonIgnore
    @Override
    public Long primaryKey() {
        return this.id;
    }

}
